package net.protocol.diameter.avp;

import java.nio.ByteBuffer;

/**
 * <pre>
 *    QoSFilterRule
 *      The QosFilterRule format is derived from the OctetString AVP Base
 *      Format.  It uses the ASCII charset.  Packets may be marked or
 *      metered based on the following information that is associated with
 *      it:

 *         Direction                          (in or out)
 *         Source and destination IP address  (possibly masked)
 *         Protocol
 *         Source and destination port        (lists or ranges)
 *         DSCP values                        (no mask or range)
 *
 *      Rules for the appropriate direction are evaluated in order, with
 *      the first matched rule terminating the evaluation.  Each packet is
 *      evaluated once.  If no rule matches, the packet is treated as best
 *      effort.  An access device that is unable to interpret or apply a
 *      QoS rule SHOULD NOT terminate the session.
 *
 *    QoSFilterRule filters MUST follow the format:
 *    Action dir proto from src to dst [options]
 *          tag    - Mark packet with a specific DSCP [DIFFSERV].  The DSCP option MUST be included.
 *          meter  - Meter traffic.  The metering options MUST be included.
 *
 *    dir   The format is as described under IPFilterRule.
 *          proto         The format is as described under IPFilterRule.
 *          src and dst  The format is as described under IPFilterRule.
 * </pre>
 *
 * @author jinhongw@gmail.com
 * @see <a href="http://tools.ietf.org/html/rfc3588#page-49">Diameter Base Protocol - QoSFilterRule</a>
 */
public class QoSFilterRule extends OctetString {

    /**
     * @param code AVP Code
     * @param rule AVP Data
     */
	public QoSFilterRule(int code, String rule) {
    	super(code, rule);
    }

    /**
     * @param code     AVP Code
     * @param vendorId Vendor-ID
     * @param rule     AVP Data
     */
	public QoSFilterRule(int code, int vendorId, String rule) {
        super(code, vendorId, rule);
    }
	
    /**
     * Creates a new <code>QoSFilterRule</code> with the given DiameterAVPHeader and source ByteBuffer
     *
     * @param header Diameter AVP Header
     * @param src The buffer from which bytes are to be retrieved
     */
    QoSFilterRule(DiameterAVPHeader header, ByteBuffer src) {
        super(header, src);
    }

    @Override
    public final DataFormat getType() {
        return DataFormat.QoSFilterRule;
    }

    @Override
    public String getName() {
        return DataFormat.QoSFilterRule.name();
    }
}
